package com.team.dutchboy.config.sentinel;

import com.team.dutchboy.service.FeignDemo;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

//feign容错类，可以获取具体异常
@Component
@Slf4j
public class FeignFallbackFactory implements FallbackFactory<FeignDemo> {
    @Override
    public FeignDemo create(Throwable throwable) {
        log.error("{}",throwable);
        return new FeignDemo() {
            @Override
            public String callPush(String message) {
                return "push异常";
            }

            @Override
            public String remoteTest(String a) {
                return "test异常";
            }

            @Override
            public String testSeata(String a) {
                throw new RuntimeException("da");

            }
        };
    }
}
